﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WooCoo.DataPortal.Server
{
    /// <summary>
    /// 数据门户调用事件参数
    /// </summary>
    public class DataPortalEventArgs : EventArgs
    {
        private DataPortalContext _portalContext;
        private DataPortalOperations _operation;
        private Exception _exception;
        private Type _objectType;

        /// <summary>
        /// 数据门户中的上下文信息.
        /// </summary>
        public DataPortalContext DataPortalContext
        {
            get { return _portalContext; }
        }

        /// <summary>
        /// 请求的操作类型.
        /// </summary>
        public DataPortalOperations Operation
        {
            get { return _operation; }
        }

        /// <summary>
        /// Gets a reference to any exception that occurred
        /// during the data portal call.
        /// </summary>
        /// <remarks>
        /// This property will return Nothing (null in C#) if no
        /// exception occurred. Exceptions are returned only as part
        /// of a data portal complete event or method.
        /// </remarks>
        public Exception Exception
        {
            get { return _exception; }
        }

        /// <summary>
        /// 需要处理的业务对象类型.
        /// </summary>
        public Type ObjectType
        {
            get { return _objectType; }
        }

        /// <summary>
        /// 构造方法.
        /// </summary>
        public DataPortalEventArgs(DataPortalContext dataPortalContext, Type objectType, DataPortalOperations operation)
        {
            _portalContext = dataPortalContext;
            _operation = operation;
            _objectType = objectType;
        }

        /// <summary>
        /// 构造方法.
        /// </summary>
        public DataPortalEventArgs(DataPortalContext dataPortalContext, Type objectType, DataPortalOperations operation, Exception exception)
            : this(dataPortalContext, objectType, operation)
        {
            _exception = exception;
        }
    }
}
